package com.javajun.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @className: SysUser
 * @description: 用户父类
 * @author: JavaJun
 * @date: 2018年11月16日
 */
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class SysUser {

    private Integer id;
    // 用户名，长度 50
    private String username;
    // 密码
    private String password;
    // 名字，长度50
    private String name;
    // 邮箱，长度50
    private String email;
    // 联系电话，长度50
    private String phone;
    // 角色,@manytomany
    private List<SysRole> sysRole = new ArrayList<>();
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(length=50, unique=true)
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    @JsonIgnore
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    
    @Column(length=50)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(length=50, unique=true)
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    
    @Column(length=50)
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    @ManyToMany(cascade=CascadeType.REFRESH, fetch=FetchType.EAGER)
    public List<SysRole> getSysRole() {
        return sysRole;
    }
    public void setSysRole(List<SysRole> sysRole) {
        this.sysRole = sysRole;
    }
}
